import sys
import traceback
from httplib2 import Http

try:
    http = Http()
    request, content = http.request('http://vnexpress.net/124123412')
    print request
        
    if (request['status'] == '200'):
        if ('image' in request['content-type']):
            fileObj = open("a.jpg","w")
            fileObj.write(content)
            fileObj.close()
        else:
            print 'not image type'
    else:
        print 'File not downloaded'
except Exception:
    print traceback.format_exc()
    pass  # not valid